<?php

namespace App\Services;

use AntChain\REALPERSON\Client as AntChainREALPERSONClient;

use AntChain\REALPERSON\Models\Config;
use AntChain\REALPERSON\Models\CheckRouteTwometaRequest;

class AlipayRealpersonService {

    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return AntChainREALPERSONClient Client
     */
    public static function createClient(){
        $config = new Config([]);
        // 您的AccessKey ID
        $config->accessKeyId = config('antchain.accessKeyId');
        // 您的AccessKey Secret
        $config->accessKeySecret = config('antchain.accessKeySecret');
        return new AntChainREALPERSONClient($config);
    }

    /**
     * 身份二要素查询
     * @param string[] $args
     * @return void
     */
        public static function main($certName,$certNo){
            $client = self::createClient();
            $checkRouteThreemetaRequest = new CheckRouteTwometaRequest([
                "certName" => $certName,
                "certNo" => $certNo,
                "outerOrderNo" => time(),
                "scene" => "COMP"
            ]);
            $res=$client->checkRouteTwometa($checkRouteThreemetaRequest);
            $result=obToArray($res);
            self::requestLog('身份二要素查询', $checkRouteThreemetaRequest, $result);
            return $result;
        }

    /**
     * 支付宝
     * @param $message
     * @param array $request
     * @param array $response
     */
    public static function requestLog($message,$request=[],$response=[]){
        $content = [
            'request'=>is_object($request) ? object_array($request) : $request,
            'response'=>is_object($response) ? object_array($response) : $response,
        ];
        \Illuminate\Support\Facades\Log::debug($message,$content);
    }

}
